
 const searchInput = document.getElementById('searchInput');
 const suggestions = document.getElementById('suggestions');
 const searchButton = document.getElementById('searchButton');
 
 searchInput.addEventListener('input', function () {
    const inputValue = searchInput.value;
    if (inputValue === '') {
        suggestions.classList.add('hidden');
    } else {
        suggestions.classList.remove('hidden');
        const liElements = suggestions.querySelectorAll('li');
        liElements.forEach((li) => {
            const text = li.textContent;
            if (text.includes(inputValue)) {
                li.style.display = 'block';
            } else {
                li.style.display = 'none';
            }
        });
        }
    });
 

    suggestions.addEventListener('click', function (event) {
        if (event.target.tagName === 'LI') {
        const selectedText = event.target.textContent;
        searchInput.value = selectedText;
        suggestions.classList.add('hidden');
        }
       });
        
        searchButton.addEventListener('click', function () {
        const searchValue = searchInput.value;
        // 这里可以添加实际的搜索逻辑，比如发送请求到后端接口
        console.log('搜索内容:', searchValue);
       });
   
       

// 添加 keyup 事件监听器
searchInput.addEventListener('keyup', (event) => {
  const searchText = event.target.value.trim().toLowerCase();
  
  // 获取所有的 <li> 元素
  const items = suggestions.getElementsByTagName('li');
  
  Array.from(items).forEach((item) => {
    const itemText = item.textContent.toLowerCase(); // 将文本转为小写以便比较
    
    if (itemText.includes(searchText)) { // 如果包含搜索关键词，则显示该项
      item.classList.remove('hidden');
    } else { // 否则隐藏该项
      item.classList.add('hidden');
    }
  });
});


searchButton.addEventListener('click', (event) => {
  const searchText = event.target.value.trim().toLowerCase();
  
  
  Array.from(items).forEach((item) => {
  
    
    if (shujuku.includes(searchText)) { // 如果包含搜索关键词，则显示该项
      console.log('找到');
      
      
    } else { // 否则隐藏该项
      console.log('没有找到');
    }
  });
});